<#if package??>
    package ${package}
</#if>

<#if imports?? && imports?size > 0>
    <#list imports as import>
        import ${import}
    </#list>
</#if>
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
import java.util.HashMap;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page

<#if service?? && service.import??>
    import ${service.import}
</#if>

<#if entity?? && entity.import??>
    import ${entity.import}
</#if>

<#if comment??>
    /**
    * ${comment}
    *
    * @author ${author}
    * @note: 基于Mybatis-Plus
    */
</#if>
@RequestMapping(value = "/${requestApi}")
@Controller
public class ${className} {

@Autowired
private ${service.className} ${service.name};

/**
* 分页读取
*
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping(value = "/list")
@ResponseBody
public Map list(
@RequestParam(required = false, defaultValue = "1") Integer pageNo,
@RequestParam(required = false, defaultValue = "10") Integer pageSize
) {

Page<${entity.className}> page = ${service.name}.page(new Page<${entity.className}>(pageNo, pageSize));

Map map = new HashMap();
map.put("code", 200);
map.put("data", page);

return map;
}

/**
* 保存
*
* @param ${entity.name}
* @return
*/
@PostMapping(value = "/save")
@ResponseBody
public Map save(${entity.className} ${entity.name}){

boolean flag = ${service.name}.save(${entity.name})

Map map = new HashMap();
map.put("code", 200);
map.put("msg", flag ? "Save SUC" : "Save Fail");

return map;
}

}
